'use strict';
/**
 * 
 * @param {Function} fn 
 * @param {*} context 
 */
function bind(fn, context) {
  console.log('1=> ' + arguments);
  // get Array since arguments[2]
  let args = Array.prototype.slice.call(arguments, 2);


  return function () {
    try {
      console.log('2=> ' + arguments);
      // transform to Array
      let addArgs = Array.prototype.slice.call(arguments),
          allArgs = addArgs.concat(args);
    } catch (e) {
      console.log(e);
    }

    // allArgs = []
    return fn.apply(context, allArgs);
  }
}

function demoFunc() {
  console.log(this.title);
}

let demoDatal1 = {
  text: 'data1'
};
let demoDatal2 = {
  text: 'data2'
};

bind(demoFunc, demoDatal1, demoDatal2);